package com.toivan.mt.model;

import android.content.Context;
import com.google.gson.Gson;
import com.toivan.mt.utils.MtJsonParser;
import com.toivan.sdk.MtSDK;

/**
 * @ClassName Portrait
 * @Description 人像抠图的Bean
 * @Author Spica2 7
 * @Date 2021/6/22 15:17
 */
public class MtPortrait {

    private String name;
    private String dir;
    private String category;
    private String thumb;
    private boolean voiced;
    private boolean downloaded;


    public MtPortrait(String name, String dir, String category, String thumb, boolean voiced, boolean downloaded) {
        this.name = name;
        this.dir = dir;
        this.category = category;
        this.thumb = thumb;
        this.voiced = voiced;
        this.downloaded = downloaded;
    }


    public void setName(String name) {
        this.name = name;
    }


    public String getName() {
        return name;
    }


    public void setDir(String dir) {
        this.dir = dir;
    }


    public String getDir() {
        return dir;
    }


    public void setCategory(String category) {
        this.category = category;
    }


    public String getCategory() {
        return category;
    }


    public void setThumb(String thumb) {
        this.thumb = thumb;
    }


    public String getThumb() {
        return MtSDK.get().getPortraitUrl() + thumb;
    }


    public void setVoiced(boolean voiced) {
        this.voiced = voiced;
    }


    public boolean getVoiced() {
        return voiced;
    }


    public void setDownloaded(boolean downloaded) {
        this.downloaded = downloaded;
    }


    public boolean getDownloaded() {
        return downloaded;
    }


    public String getUrl() {
        return MtSDK.get().getPortraitUrl() + dir + ".zip";
    }


    public void portraitDownload(Context context) {
        MtPortraitManager manager = MtJsonParser.getInstance().getPortraitManager();
        if (manager != null) {
            manager.findPortrait(this.name).setDownloaded(true);
            MtJsonParser.getInstance().portraitsDownload( new Gson().toJson(manager));
        }
    }

}
